package com.jyx.bank;

import java.util.Scanner;

public class Test {

	static int ScendMenu(Atm atm,FileIO file){
		Scanner rd=new Scanner(System.in); 
		int num = 0;
		System.out.println("**********************************");
		System.out.println("**             1.取钱                                           **");
		System.out.println("**             2.存钱                                            **");
		System.out.println("**            3.显示余额                                      **");
		System.out.println("**             4.退出                                            **");
		System.out.println("**********************************");
		num = rd.nextInt();
		if(num == 1){
			atm.GetMoney();
		}
		else if(num == 2){
			atm.PutMoney();
		}
		else if(num == 3){
			atm.Balance();
		}
		else if(num == 4){
			return 0;
		}
		else{
			System.out.println("选项不存在");
		}
		return 1;
	}
	
	static int FristMenu(Atm atm,FileIO file){
		Scanner rd=new Scanner(System.in); 
		int num = 0;
		System.out.println("**********************************");
		System.out.println("**             1.登录                                            **");
		System.out.println("**             2.注册                                            **");
		System.out.println("**             3.退出                                           **");
		System.out.println("**********************************");
		num = rd.nextInt();
		if(num == 1){
			if(atm.Login() == 1){
				while(ScendMenu(atm,file) != 0){};
			}
		}
		else if(num == 2){
			atm.Registration();
		}
		else if(num == 3){
			return 0;
		}
		else{
			System.out.println("选项不存在");
		}
		return 1;
	}
	static public void main (String args[])
	{
		Atm atm = new Atm();
		FileIO file = new FileIO("C:/one.txt");//在这修改存放文件的位置
		file.input();
		atm.innumber(file.RN(), file.RP(), file.RNu());
		while(FristMenu(atm,file) != 0){}
		file.innumber(atm.RN(), atm.RP(), atm.RNu());
		file.output();
	}
}

